package com.koicarp.university.graduate.service.service.recurit.impl;

import com.koicarp.university.graduate.service.dao.TeacheInDao;
import com.koicarp.university.graduate.service.entity.TeacheIn;
import com.koicarp.university.graduate.service.service.recurit.TeacheInService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 【宣讲会管理；宣讲会信息表】(TeacheIn)表服务实现类
 *
 * @author liutao
 * @since 2020-07-30 17:23:25
 */
@Service("teacheInService")
public class TeacheInServiceImpl implements TeacheInService {
    @Resource
    private TeacheInDao teacheInDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TeacheIn queryById(Integer id) {
        return this.teacheInDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TeacheIn> queryAllByLimit(int offset, int limit) {
        return this.teacheInDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param teacheIn 实例对象
     * @return 实例对象
     */
    @Override
    public TeacheIn insert(TeacheIn teacheIn) {
        this.teacheInDao.insert(teacheIn);
        return teacheIn;
    }

    /**
     * 修改数据
     *
     * @param teacheIn 实例对象
     * @return 实例对象
     */
    @Override
    public TeacheIn update(TeacheIn teacheIn) {
        this.teacheInDao.update(teacheIn);
        return this.queryById(teacheIn.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.teacheInDao.deleteById(id) > 0;
    }
}